from appium import webdriver


class Base():
    def __init__(self):
        cap={"platformName": "Android",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "uiautomator2",
  "appium:appPackage": "com.kongfz.app",
  "appium:appActivity": ".home.mvvm.homepage.HomeActivity",
  "appium:noReset": True}
        #远程连接
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        #隐式等待
        self.driver.implicitly_wait(20)
    def find_ele(self,loc):
        ele=self.driver.find_element(*loc)
        return ele
    #轻敲

    def qingqiao(self,x,y):
        self.driver.tap([(x,y)],200)
    #滑动
    def huadong(self,a,b,c,d):
        self.driver.swipe(a,b,c,d)
    #截图
    def jietu(self,a):
        self.driver.save_screenshot(a)
    #退出驱动
    def tuicu(self):
        self.driver.quit()
